extends IBasicComponent


class_name PropertyComponent
"""
属性组件
"""


## 属性值变更
signal event_value_will_changed(cmpt: PropertyComponent, v_name: StringName, current_v: Variant, new_v: Variant)


# 校验并转换数据
func __check_value(property: StringName, v: Variant) -> Variant:
    # 不需要校验,直接返回
    return v

# 用于在属性中使用set赋值,附带事件通知
func __set_value(property: StringName, current_v: Variant, new_v: Variant, is_skip_check: bool = false) -> Variant:
    var update_v: Variant = new_v if is_skip_check else __check_value(property, new_v)
    if current_v != update_v:
        event_value_will_changed.emit(self, property, current_v, update_v)
        return update_v
    return current_v
